package com.zhuoshi.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.zhuoshi.bean.ContractReportBean;
import com.zhuoshi.utils.DbHelper;

/**
 * 销售综合报表
 * @author Administrator
 *
 */
public class ContractReportDao {
	public List<ContractReportBean> getList(){
		Connection conn = null;
		PreparedStatement pstat = null;
		ResultSet rs = null;
		
		List<ContractReportBean> list = new ArrayList<ContractReportBean>();
		try {
			conn = DbHelper.getConnection();
			StringBuffer sql = new StringBuffer();
			sql.append("select cs.id,cs.numerical,cs.sqarename,cm.customerid,cs.modeltype,cs.totalcount,cs.price,cm.condate,cs.totalmoney from contractsub cs LEFT JOIN contractmaster cm on cs.numerical=cm.numerical");
			pstat = conn.prepareStatement(sql.toString());
			rs = pstat.executeQuery();
			while(rs.next()){
				ContractReportBean bean = new ContractReportBean();
				bean.setId(rs.getInt("id"));
				bean.setNumerical(rs.getInt("numerical"));
				bean.setSqarename(rs.getString("sqarename"));
				bean.setCustomerid(rs.getInt("customerid"));
				bean.setModeltype(rs.getString("modeltype"));
				bean.setTotalcount(rs.getInt("totalcount"));
				bean.setPrice(rs.getDouble("price"));
				bean.setCondate(rs.getDate("condate"));
				bean.setTotalmoney(rs.getDouble("totalmoney"));
				list.add(bean);
								
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			DbHelper.dispose(conn, pstat, rs);
		}
		
		return list;
	}

}
